// import { useState } from 'react';
import { Button, View } from '@tarojs/components';
import { LoginApi } from '@/api';
import './index.scss';

interface IProps {
  show: boolean;
  handleShow: (show: boolean) => void;
}

// interface UserTypes {
//   username: string;
//   password: string;
//   loginType: string;
// }

function ComponentLogin(props: IProps) {
  const onLogin = async () => {
    try {
      const params = {
        username: 'admin',
        password: 'SDzs2023@123456',
        loginType: 'VERIFICATION'
      };
      await LoginApi(params);
    } catch (e) {
      console.log(e);
    }
  };
  // const [user, setUser] = useState<UserTypes>({
  //   username: 'admin',
  //   password: 'SDzs2023@123456',
  //   loginType: 'VERIFICATION'
  // });

  return (
    <View>
      {props.show && (
        <View onClick={() => props.handleShow(false)}>
          <View>登录</View>
          <Button onClick={onLogin}>登录</Button>
        </View>
      )}
    </View>
  );
}

ComponentLogin.displayName = 'ComponentLogin';

// @ts-ignore
export default ComponentLogin;
